import http from './http'
import type {
  LoginRequestData,
  LoginResponseData,
  RegisterRequestData,
  RegisterResponseData,
  UserProfileResponseData
} from '@/types/api'

export const login = async ({
  username,
  password
}: LoginRequestData): Promise<LoginResponseData> => {
  return http.post('/auth/login', {
    username,
    password
  })
}

export const register = async ({
  username,
  password,
  email
}: RegisterRequestData): Promise<RegisterResponseData> => {
  return http.post('/auth/register', { username, password, email })
}

export const getUserProfile = async (): Promise<UserProfileResponseData> => {
  return http.get(`/user/profile/info`)
}
